package com.ruoyi.edu.client;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.edu.api.domain.vo.EduCourseVO;
import com.ruoyi.edu.api.feign.IEduClient;
import com.ruoyi.edu.service.IEduCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Alex
 * @version 1.0
 * @date 2023/9/23 10:48
 */
@RestController
public class EduClient implements IEduClient {

    @Autowired
    private IEduCourseService eduCourseService;

    /**
     * 远程调用，order模块创建订单时向edu模块获取课程信息
     *
     * @param courseId 课程id
     * @return 课程详细信息
     */
    @Override
    @RequestMapping("/edu/course/{courseId}")
    public AjaxResult getCourseInfo(@PathVariable("courseId") String courseId) {
        EduCourseVO courseVO = eduCourseService.selectEduCourseById(courseId);
        return null == courseVO? AjaxResult.error("课程信息不存在"): AjaxResult.success(courseVO);
    }
}
